refactor(scrape): adopt kit/console/cli + conventions parity#5
Merged
Conversation
replace hand-rolled os.Args switch with cli.New root single-shot leaf: <url> positional, ExactArgs(1) kit globals for free (--version --quiet --no-color --format -V -C --help-all) --ext-info intercepted pre-cobra, four-field discovery contract intact side-effect=read, idempotent=yes annotations usage/bad-flag exit 2 via output.UsageError envelope drop dead io.Discard import hack
drop --readability/--raw boolean pair add --mode <readability|raw>, default readability validate enum in RunE, reject unknown value as usage error (exit 2)
wire in-process kitbus.New + NetworkAdapter (source foo-scrape).
peers from FOO_SCRAPE_BUS_PEERS; auth FOO_BUS_TOKEN/BUS_TOKEN.
publish foo-scrape.capture.page.scraped {url, mode} on success.
connect failures warn-logged, never fatal; no --offline flag.
ext-info contract + exit codes unchanged.
d1769b1 to
7da62d6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Migrates the
foo-scrapesidecar from a hand-rolledos.Argsparser tokit/console/cli, resolving the red-verdict findings from the CLI review.Changes
cli.New.<url>becomes a positional. Brings the kit-owned globals (--version,--quiet,--no-color,--format,-V,-C,--help-all) for free.--modeenum — replace the mutually-overriding--readability/--rawbooleans with--mode <readability|raw>(defaultreadability), validated.ioimport +io.Discardsuppression hack.foo-scrape.capture.page.scrapedafter a successful scrape; failed scrapes publish nothing. Network adapter tolerant of connect failure.Contract preserved
--ext-infostill emits the exact four-field discovery JSON (name,version,description,capabilities), exit 0 — the host's plugin discovery depends on it.Verification
go build ./...+go vet ./cmd/foo-scrape/...clean.--help,--modevalidation, and exit codes probed.